programming4us
           
 
 
Sharepoint

Working with Search Page Layouts : Modify the Search Results Presentation (part 1)

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
8/19/2011 9:29:50 AM
Search results in SharePoint 2010 offer great opportunities for modification. Many can be done through the UI, but some changes require a little more modification. This section offers some insight into the possibilities through examples of how to add and remove search result information and how to modify the behavior of search results.

1. Adding Additional Info to Search Results with XSLT

When searching in SharePoint using default search centers, only a small portion of the available data is actually presented to the user. Often adding new information is as easy as just modifying the XSLT template to display another property value. Sometimes, however, some form of interactivity with the search results is desired. This section focuses on how to enrich the search result UI through an example with ratings.

2. Enabling Ratings

To get started, obviously ratings needs to be turned on in at least one list or library. For this example, a document library containing a number of PowerPoint presentations and a few documents is used. To enable ratings, navigate to the document library and choose "List settings" from the ribbon. From the Document Library settings page, choose "Rating settings", which opens a page where it is possible to enable or disable ratings as seen in Figure 1.

Figure 1. Enabling ratings

Once this setting is made, a new column is added to the list and to the default view as seen next in Figure 2. At this point users can start rating content.

Figure 2. Rating controls displayed in document library

NOTE

When selecting a rating and then doing a page reload, it can happen that the page is not updated with the latest rating due to a delay in processing ratings in SharePoint.

As you click the stars and add a rating, this is logged by SharePoint through an asynchronous AJAX call. An automated timer job in SharePoint named Social Data Maintenance Job is responsible for calculating the average ratings. The ratings are stored in the SocialRatings_Averages table. The rating information is computed from data in that table.

3. Making Ratings Searchable

To allow data (in this case, ratings) to be searchable, it must be exposed as a searchable property. More precisely, this is done by creating a managed property in search to be included in the search results. To create the managed property, a crawled property is required. When the properties are fully configured, perform a full crawl for the properties to become available for searching.

If you are uncertain if these properties already exist, go to the Search Administration page in Central Administration. There open the Metadata Properties link located on the navigation bar to the left, and click the Crawled Properties link. Search for the term "rating." as seen in Figure 3.

Figure 3. Checking properties for rating

If it already exists, the result should show two hits, one for ows_AverageRating and another for ows_RatingCount. If no hits are returned, make sure that rating is enabled on a document library, start a full crawl in search, and wait for it to complete.

When the crawled properties exist, then add a managed property for each of the two crawled properties. Begin with the ows_AverageRating and create a managed property named "Rating." as seen in Figure 4. This value is of a decimal type, and choose the ows_AverageRating crawled property for the mapping.

Figure 4. Added managed properties for rating

Next, add a managed property named RatingCount the same way as with the Rating property. It should be mapped to the crawled property named ows_RatingCount and have the type set to Integer. Ensure both of the crawled properties are included in the index. This is done by selecting the "Include values for this property in the search index" check box on each crawled property. After all of these changes have been made, again do a full crawl of search.

NOTE

An incremental crawl does not update the index when changing managed and crawled properties. When doing structural changes, a full crawl is required.

4. Adding Ratings to Search Results

When the managed properties are added and a full crawl is completed, the XSL template must be modified to show the rating in the search results Web Part. Open the search results page that needs ratings added to it, and go to edit mode. Now change the following three settings of the Display Properties on the core search result Web Part.

Find the Use Location Visualization setting, and make sure it is unchecked.

Find the fetched properties. Here two new managed properties must be added. It should be expanded to contain these:

<Column Name="Rating"/>
<Column Name="RatingCount"/>

Find the XSL button and click it. Update the XSL to include the ratings. An example of how it could look is covered next. It is good practice to make a backup of the existing XSL before editing it. This way it is easier to go back to scratch in case the XSL gets wrongly edited.

For ease of use, it is suggested to insert a call template block in the XSL template. For those not too familiar with XSL, this is just a placeholder that displays the XSL formatting template block to apply and which variables to use in the template block. It can conceptually be understood as a method that gets called.

Two variables are required: Rating and Rating Count. These properties are exposed to the formatting template block with the same names for easier reading. The formatting template block is named DisplayRating.

<xsl:template name="DisplayRating">
<xsl:param name="rating" />
<xsl:param name="ratingcount" />
Rating: <xsl:value-of select="format-number($rating, '#.#')" />
(rated <xsl:value-of select="$ratingcount" /> times)
</xsl:template>

The next step is to include the required markup in the XSL template where the DisplayRating template is to be rendered, and the conditions under which it should be rendered. A suitable location in the layout for the rating to be displayed is just before the hit highlighted summary.

Notice that a test is performed to verify that the rating is higher than 0. This is only the case if the item—in this case, documents—has a rating. If the document has a rating, the DisplayRating template just shown is called and the rating text is rendered into the layout.

<div class="srch-Description2">

<xsl:if test="rating &gt; 0">
<b>
<xsl:call-template name="DisplayRating">
<xsl:with-param name="rating" select="rating" />
<xsl:with-param name="ratingcount" select="ratingcount" />
</xsl:call-template>
</b><br />
</xsl:if>

<xsl:choose>
<xsl:when test="hithighlightedsummary[. != '']">
<xsl:call-template name="HitHighlighting">
<xsl:with-param name="hh" select="hithighlightedsummary" />
Other -----------------
- Working with Search Page Layouts : Applying a Branded Master Page to a Search Center
- SharePoint 2010 : Excel Services - User-Defined Functions
- SharePoint 2010 : Using the Excel Services REST API
- SharePoint 2010 : Social Sites: Providing a Structure for Collaborative Conversations
- SharePoint 2010 : Social Data: Enhancing Value with User Contributed Content
- Sharepoint 2010 : Excel Service - Demonstration Scenario (part 3)
- Sharepoint 2010 : Excel Service - Demonstration Scenario (part 2)
- Sharepoint 2010 : Excel Service - Demonstration Scenario (part 1)
- Working with Search Page Layouts : Adding Navigation to the Search Center (part 2)
- Working with Search Page Layouts : Adding Navigation to the Search Center (part 1) - Adding Home and Back Buttons to the Search Result Page
- Working with Search Page Layouts : Understanding Master Pages in SharePoint 2010
- Sharepoint 2010 : Social Networking - Engaging People
- Sharepoint 2010 : Developing a Strategy for SharePoint Community Features
- SharePoint 2010 : SQL Server Reporting Services 2008 (part 3) - Installing and Configuring SQL Server Reporting Services 2008
- SharePoint 2010 : SQL Server Reporting Services 2008 (part 2) - Understanding the Architecture of SQL Server Reporting Services 2008
- SharePoint 2010 : SQL Server Reporting Services 2008 (part 1)
- SharePoint 2010 : Configuring Excel Services
- Excel Capabilities on SharePoint 2010
- Setting Up UAG for SharePoint (part 2) - Publishing SharePoint Through a Portal Trunk in UAG
- Setting Up UAG for SharePoint (part 1) - Setting Up SharePoint for Cross-Firewall Access & Creating Application Portal Trunk in UAG
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us